class Solution
{
public:
    bool isRobotBounded(string instructions)
    {
        int x = 0;
        int y = 0;
        int direction = 0;
        for (int _ = 0; _ < 4; ++_)
        {
            for (char c : instructions)
            {
                switch (c)
                {
                case 'L':
                    direction = (direction + 1) % 4;
                    break;
                case 'R':
                    direction = (direction + 3) % 4;
                    break;
                case 'G':
                    switch (direction)
                    {
                    case 0:
                        ++y;
                        break;
                    case 1:
                        --x;
                        break;
                    case 2:
                        --y;
                        break;
                    case 3:
                        ++x;
                        break;
                    }
                    break;
                }
            }
        }
        if (x == 0 && y == 0)
        {
            return true;
        }
        return false;
    }
};